#ifndef __TREE_H__
#define __TREE_H__

typedef struct node_t{
	struct node_t *left;
	struct node_t *right;
	char data[0];
}node;

typedef struct head_t{
	node *root;
	int size;
}head;

typedef int (*cmp_t)(const void *data1, const void *data2);
typedef void (*pri_t)(const void * data);

int root_init(head **tree, const int size);
int tree_insert(head *tree, const void *data, cmp_t cmp);
int tree_delete(head *tree, const void *data, cmp_t cmp);
void * tree_find(const head *tree, const void *key, cmp_t cmp);
void tree_travel(const head *tree, pri_t pri);
void tree_destroy(head **tree);
void tree_balance(head *tree);

#endif
